<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<html>
<head>
<title>我的购物车</title>
<%@ include file="/commons/metaf.jsp" %>
<%@ include file="/commons/meta-easyui.jsp" %>
<script type="text/javascript">
	function removeGoods(id){
		//alert();
		$.post('${ctx}/Shopping/delete.do',{id:id},function(data){
			if (data.result) {
				$("#tr_"+id).remove();
			}
		},'json');
	}
	//重新计算总价
	function priceCalc(){
		//得到每行的第二列
		//得到每行的第三列
		//得到每行的第五列
		var total=0;
		var total_dis=0;
		$(".c9").each(function(i){
			var price = $(this).text().substring(1);
			var price_dis = $(".red :eq("+i+")").text().substring(1);
			var count = $(".count :eq("+i+")").val();
			//alert(count);
			total+=(price*count);
			total_dis+=(price_dis*count).toFixed(2);
		});
		$(".a_c").text('￥'+total_dis);
		$(".a_d_c").text('你共节省：￥'+(total-total_dis).toFixed(2));
	}
</script>
</head>
<body>
<div id="container">
	<iframe id="header" src="<c:url value="/pagesf/header.jsp"></c:url>" width="980" height="136" frameborder="0" scrolling="no"></iframe>
		<div class="buy">

			<table class="buy" cellpadding="0" cellspacing="0">
				<tbody id="priceTable">
					<tr class="buytitle">
						<td colspan="6" class="b">确认商品价格与数量</td>
					</tr>
					<tr>
						<td class="w364 b">&nbsp;&nbsp;&nbsp;&nbsp;商品名</td>
						<td class="w100 b">原价</td>
						<td class="w100 b">优惠价</td>
						<td class="w100 b">打折</td>
						<td class="w100 b">数量</td>
						<td class="w81 b">删除</td>
					</tr>
					<c:forEach items="${cartInfo }" var="info">
					
					<tr class="h26 blue" id="tr_${info.key.id }">
						<td><a href="${ctx }/Goods/show.do?flag=true&id=${info.key.id }" title="${info.key.name }">&nbsp;&nbsp;&nbsp;&nbsp;${info.key.name }</a></td>
						<td><span class="c9">￥<fmt:formatNumber pattern="0.00">${info.key.price }</fmt:formatNumber></span></td>
						<td>
						<span class="red">￥<fmt:formatNumber pattern="0.00">${info.key.price*info.key.discount }</fmt:formatNumber>
						</span>
						</td>
						<td><span class="black">${info.key.discount*10}折</span></td>
						<td>
							<input class="count" onchange="priceCalc()" type="text" value="${info.value }" maxlength="4" size="3" />
						</td>
						<td><a href="JavaScript:void(0)" onclick="removeGoods(${info.key.id })">删除</a></td>
					</tr>
					</c:forEach>
					
					<tr class="h26">
						<%-- <td>&nbsp;&nbsp;&nbsp;&nbsp;<a href="${ctx }/Index.do">继续挑选商品</a></td> --%>
						<td></td>
						<td></td>
						<td class="a_c" colspan="2" id="sum" class="pl58">￥${total_dis }</td>
						<td class="a_d_c" colspan="3">你共节省：￥${total-total_dis }</td>
					</tr>
				</tbody>
			</table>
			<a href="${ctx }/Index.do" class="easyui-linkbutton"
						onclick="">继续购物</a>
			<a href="javascript:;" class="easyui-linkbutton"
						onclick="">提交</a>
		</div>
		<iframe id="footer" src="<c:url value="/pagesf/footer.jsp"></c:url>" width="980" height="136" frameborder="0" scrolling="no"></iframe>
</div> <!--container end-->	
</body>
</html>